﻿<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Financial Tracking</title>
<script src="${pageContext.request.contextPath}/js/jquery.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/global.js" type="text/javascript"></script>

<link rel="stylesheet" href="${pageContext.request.contextPath}/css/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/styles.css" type="text/css" />

<script>
	$("head").append('<link rel="icon" type="image/icon" href="${pageContext.request.contextPath}/images/mini-icon.ico">');
	var DEFAULT_SCROLL = 34500;
	var loadingScroll = DEFAULT_SCROLL;
	var start = 0;
	var end = 1000;
	var cntAll = 0;
	var totalSalaryAmount = 0;
	var totalDischarge = 0;
	var totalChargeRule = 0;
	var totalCompensation = 0;
	
	var totalOrfHMain = 0;
	var totalOrfNHSO = 0;
	
	var totalSumHC = 0;
	var totalSumAE = 0;
	var totalSumINST = 0;
	var totalSumIP = 0;
	var totalSumDMIS = 0;
	var totalSumOP = 0;
	var totalSumPA = 0;
	var totalSumOT = 0;
	var totalSumDRUG = 0;
	
	var totalOldTotal = 0;
	var totalOldSumHC = 0;
	var totalOldSumAE = 0;
	var totalOldSumINST = 0;
	var totalOldSumIP = 0;
	var totalOldSumDMIS = 0;
	var totalOldSumOP = 0;
	var totalOldSumPA = 0;
	var totalOldSumOT = 0;
	var totalOldSumDRUG = 0;
	var totalOldAmount = 0;
	
	var totalNewSumHC = 0;
	var totalNewSumAE = 0;
	var totalNewSumINST = 0;
	var totalNewSumIP = 0;
	var totalNewSumDMIS = 0;
	var totalNewSumOP = 0;
	var totalNewSumPA = 0;
	var totalNewSumOT = 0;
	var totalNewSumDRUG = 0;
	var totalNewDischarge = 0;
	var totalNewCompensation = 0;
	
	var totalPay = 0;
	var totalReturn = 0;
	
	var countStatusA = 0;
	$(function() {
		$(".loader").fadeOut("slow");
		$("#searchBy").val("${SESSION_SUMMARY.pageDetailsData.searchBy}");
		if($("#searchBy").val() === "status"){
			$("#searchByStatus").val("${SESSION_SUMMARY.pageDetailsData.value}");
			$("#searchByStatus").show();
			$("#txtSearch").hide();
		}else{
			$("#searchByStatus").hide();
			$("#txtSearch").val("${SESSION_SUMMARY.pageDetailsData.value}");	
			$("#txtSearch").show();
		}

		$("#fromDate").html(toDatepickerValue("${SESSION_SUMMARY.fromDateStr}"));
		$("#toDate").html(toDatepickerValue("${SESSION_SUMMARY.toDateStr}"));

		var hospitalCode = "${SESSION_SUMMARY.pageDetailsData.hospital.hospitalCode }";
		var len = hospitalCode.length;
		$("#hospitalCode").html(hospitalCode.substring(len - 5, len));

		$("#btnSearch").click(function() {
			var searchBy = $("#searchBy").val();
			var searchValue = $("#txtSearch").val();
			if(searchBy === "status"){
				searchValue = $("#searchByStatus").val();
			}
			clearData();
			$.ajax({
				url: '${pageContext.request.contextPath}/summary/details/data/getListDetails',
				data: {start: start, end: end, searchBy: searchBy.trim(), value: searchValue.trim()},
				type: 'POST',
				success : function(data) {
					var arrays = data;$("#tbBodyData tbody").html('')
					appendHTMLData(arrays, $("#tbBodyData tbody").html(), false);
				}
			});
		});
						
		$("#searchBy").change(function(){
			var val = $(this).val();
			if(val === "status"){
				$("#txtSearch").hide();
				$("#searchByStatus").show();
			}else{
				$("#txtSearch").val('');
				$("#txtSearch").show();
				$("#searchByStatus").hide();
			}
		});
	});
	
	$(function(){
		var rowspan_thead1 = "2746px";
		var rowspan_thead2 = "5880px";
		$("#hide_table").hide();
		$("#tbValueData").css("height","395px");
		$(".hidden-table").hide();
		$("#thead2").hide();
		
		$("#tbHeaderData").attr("width",rowspan_thead1);
		$("#tbBodyData").attr("width",rowspan_thead1);
		
		$("#show_table").click(function(){

			$("#tbHeaderData").attr("width",rowspan_thead2);
			$("#tbBodyData").attr("width",rowspan_thead2);
			
			$("#tbValueData").css("height","390px");
			
			$("#thead1").hide();
			$("#thead2").show();
			
			$(".hidden-table").show();
			
			$("#show_table").hide();
			$("#hide_table").show();
		});
		
		$("#hide_table").click(function(){

			$("#tbHeaderData").attr("width",rowspan_thead1);
			$("#tbBodyData").attr("width",rowspan_thead1);
			
			$("#tbValueData").css("height","395px");
			
			$("#thead1").show();
			$("#thead2").hide();
			
			$(".hidden-table").hide();
			
			$("#show_table").show();
			$("#hide_table").hide();
		});
		
		$('#tbValueData').scroll( function() {
			var fromtop = $(this).scrollTop();

			if (fromtop > loadingScroll) {
				loadingScroll += DEFAULT_SCROLL;
				start += 1000;
				end += 1000;
				var searchBy = $("#searchBy").val();
				var searchValue = $("#txtSearch").val();
				if(searchBy === "status"){
					searchValue = $("#searchByStatus").val();
				}
				$.ajax({
					url: '${pageContext.request.contextPath}/summary/details/data/getListDetails',
					data: {start: start, end: end, searchBy: searchBy.trim(), value: searchValue.trim()},
					type: 'POST',
					success:function(data){
						var arrays = data;
						appendHTMLData(arrays, $("#tbBodyData tbody").html(), false);
					}
				});
			}
		});
		
		$.ajax({
			url: '${pageContext.request.contextPath}/summary/details/data/getListDetails',
			data: {start: start, end: end, searchBy: '', value: ''},
			type: 'POST',
			async: false,
			success:function(data){
				var arrays = data;
				appendHTMLData(arrays, '', true);
			}
		});
		
		$("#exportExcel").click(function(){
			window.open('${pageContext.request.contextPath}/summary/details/data/${SESSION_SUMMARY.pageDetailsData.repNo}');
		});
	});
	
	function appendHTMLData(arrays, tb, fromLoad){
		var cntPersonAppeal = 0;
		var cntPersonNotPass = 0;
		var cntStandardNotPass = 0;
		var sumsTotal = 0;
		var actAmount = 0;
		if(arrays.length > 0){
			for(var i in arrays){
				var obj = arrays[i];
				actAmount += obj.compensation;
				sumsTotal += obj.discharge;
				//if(fromLoad){
					cntAll = obj.cntAllpid;
					$('#cntAllpid').html(toMoneyFormat(obj.cntAllpid));
					$('#personPass').html(toMoneyFormat(obj.cntPass < 0 ? '0' : obj.cntPass));
					$('#personAppeal').html(toMoneyFormat(obj.cntAppeal < 0 ? '0' : obj.cntAppeal));
					$('#personNotPass').html(toMoneyFormat(obj.cntNotPassC < 0 ? '0' : obj.cntNotPassC));
					$('#standardNotPass').html(toMoneyFormat(obj.cntNotPass < 0 ? '0' : obj.cntNotPass));
					$('#sumsTotal').html(currency2Digit(obj.sumsTotal));
					$('#sumsNotPass').html('0.00');
					$('#sumsNotPassC').html('0.00');
					$('#sumsActAmount').html(currency2Digit('${SESSION_SUMMARY.pageDetailsData.actAmount}'));
				//}
				var status = 'ผ่าน';
				var clazz = '';
				var clazzTD = '';
				
				if(obj.status === 'A'){
					cntPersonAppeal++;
					status = 'อุทธรณ์';
					clazz = 'pointer-cursor ' + obj.parentTranId + ' ' + obj.discharge + ' ' + obj.compensation + ' ' + obj.fund;
				}else if(obj.codeId === '' || obj.codeId === null){
					status = 'ผ่าน';
					clazzTD = '';
				}else if(obj.codeId === 'DENY'){
					cntStandardNotPass++;
					var statusDeny = '';
					
					if(obj.hc !== 'N' && obj.hc !== 'C' && obj.hc !== null){
						statusDeny = obj.hc;
					}
					if(obj.ae !== 'N' && obj.ae !== 'C' && obj.ae !== null){
						if(statusDeny !== ''){
							statusDeny += ', ';
						}
						statusDeny += obj.ae;
					}
					if(obj.inst !== 'N' && obj.inst !== 'C' && obj.inst !== null){
						if(statusDeny !== ''){
							statusDeny += ', ';
						}
						statusDeny += obj.inst;
					}
					if(obj.ip !== 'N' && obj.ip !== 'C' && obj.ip !== null){
						if(statusDeny !== ''){
							statusDeny += ', ';
						}
						statusDeny += obj.ip;
					}
					if(obj.dmis !== 'N' && obj.dmis !== 'C' && obj.dmis !== null){
						if(statusDeny !== ''){
							statusDeny += ', ';
						}
						statusDeny += obj.dmis;
					}
					status = 'ไม่เข้าเกณฑ์<br>(' + statusDeny + ')';
					clazzTD = 'required';
				}else{
					cntPersonNotPass++;
					status = 'ไม่ผ่าน<br>(';
					var tmps = obj.codeId.split(",");
					for(var j=0; j<tmps.length; j++){
						if(j === 0){
							status += 'C' + tmps[j];
						}else{
							status += ', C' + tmps[j];
						}
					}
					status += ')';
					clazzTD = 'required';
				}
				
				if(obj.orf){
					status += '<br>(ORF)*';
					if('${SESSION_SUMMARY.pageDetailsData.status}' === 'transfer'){
						$("#orfTransfer").html("*หมายเหตุ ORF=เบิกจ่ายจากต้นสังกัด");
					}else{
						$("#orf").html("*หมายเหตุ ORF=เบิกจ่ายจากต้นสังกัด");
					}
				}
				
				var totalDisCom = obj.discharge - obj.compensation;
				var clazzDisCom = '';
				if(totalDisCom < 0){
					clazzDisCom = 'required';
				}
				
				tb += '<tr class="' + clazz + '" id="' + obj.pid + '" title="' + obj.pid + ' ' + obj.fullname + '">';
				tb += '<td width="40px">' + nullToEmpty(obj.id) + '</td>';
				tb += '<td width="100px">' + nullToEmpty(obj.tranId) + '&nbsp;</td>';
				tb += '<td width="100px">' + nullToEmpty(obj.eclaimNo) + '&nbsp;</td>';
				tb += '<td width="70px">' + nullToEmpty(obj.hn) + '&nbsp;</td>';
				tb += '<td width="70px">' + nullToEmpty(obj.an) + '&nbsp;</td>';
				tb += '<td width="95px">' + nullToEmpty(obj.pid) + '</td>';
				tb += '<td width="50px">' + nullToEmpty(obj.personType) + '</td>';
				tb += '<td width="180px" align="left">&nbsp;' + nullToEmpty(obj.fullname) + '</td>';
				tb += '<td width="110px">' + nullToEmpty(obj.admidDate) + '&nbsp;' + nullToEmpty(obj.admidTime) + '</td>';
				tb += '<td width="110px">' + nullToEmpty(obj.dischargeDate) + '&nbsp;' + nullToEmpty(obj.dischargeTime) + '</td>';
				tb += '<td width="70px">' + nullToEmpty(obj.salaryPercent) + '</td>';						
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.salaryAmount)) + '&nbsp;</td>';
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.discharge)) + '&nbsp;</td>';
				tb += '<td width="60px" class="' + clazzTD + '">' + nullToEmpty(status) + '</td>';								
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.chargeRule)) + '&nbsp;</td>';
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.compensation)) + '&nbsp;</td>';									
				tb += '<td width="100px" align="right" class="' + clazzDisCom + '">' + nullToEmpty(currency2Digit(totalDisCom)) + '&nbsp;</td>';
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.orfHMain)) + '&nbsp;</td>';			
				tb += '<td width="100px" align="right">' + nullToEmpty(currency2Digit(obj.orfNHSO)) + '&nbsp;</td>';			
				
				if(obj.hc === 'C'){
					if(obj.sumsHC !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsHC)) + '">' + nullToEmpty(currency2Digit(obj.sumsHC)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.hc === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.hc) + '&nbsp;</td>';
				}
				
				if(obj.ae === 'C'){
					if(obj.sumsAE !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsAE)) + '">' + nullToEmpty(currency2Digit(obj.sumsAE)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.ae === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.ae) + '&nbsp;</td>';
				}
				
				if(obj.inst === 'C'){
					if(obj.sumsINST !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsINST)) + '">' + nullToEmpty(currency2Digit(obj.sumsINST)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.inst === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.inst) + '&nbsp;</td>';
				}
				
				if(obj.ip === 'C'){
					if(obj.sumsIP !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsIP)) + '">' + nullToEmpty(currency2Digit(obj.sumsIP)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.ip === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.ip) + '&nbsp;</td>';
				}
				
				if(obj.dmis === 'C'){
					if(obj.sumsDMIS !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsDMIS)) + '">' + nullToEmpty(currency2Digit(obj.sumsDMISStr)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.dmis === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.dmis) + '&nbsp;</td>';
				}
				
				if(obj.op === 'C'){
					if(obj.sumsOP !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsOP)) + '">' + nullToEmpty(currency2Digit(obj.sumsOP)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.op === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.op) + '&nbsp;</td>';
				}
				
				if(obj.pa === 'C'){
					if(obj.sumsPA !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsPA)) + '">' + nullToEmpty(currency2Digit(obj.sumsPA)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.pa === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.pa) + '&nbsp;</td>';
				}
				
				if(obj.sumsDRUG !== 0){
					tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsDRUG)) + '">' + nullToEmpty(currency2Digit(obj.sumsDRUG)) + '&nbsp;</td>';
				}else{
					tb += '<td width="100px">&nbsp;</td>';
				}
				
				if(obj.ot === 'C'){
					if(obj.sumsOT !== 0){
						tb += '<td width="100px" class="amount" title="' + nullToEmpty(currency2Digit(obj.sumsOT)) + '">' + nullToEmpty(currency2Digit(obj.sumsOT)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px">&nbsp;</td>';
					}
				}else if(obj.ot === 'N'){
					tb += '<td width="100px">&nbsp;</td>';
				}else{
					tb += '<td width="100px">' + nullToEmpty(obj.ot) + '&nbsp;</td>';
				}
				
				if(obj.status !== 'A'){
					tb += '<td style="color: blue" class="hidden-table" style="width:1020px" colspan="11"> ไม่มีอุทธรณ์</td>'; 
					tb += '<td style="color: blue" class="hidden-table" style="width:1020px" colspan="11"> ไม่มีอุทธรณ์</td>';
					tb += '<td style="color: blue" style="width:100px" colspan="1" class="hidden-table"></td>';
					tb += '<td style="color: blue" style="width:100px" colspan="1" class="hidden-table"></td>';
				}else{
					tb += '<td width="100px" style="text-align:right" class="hidden-table">' + nullToEmpty(currency2Digit(obj.oldTotal)) + '&nbsp;</td>';
					
					if(obj.oldHC === 'C'){
						if(obj.oldSumsHC !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsHC)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsHC)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldHC === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldHC) + '&nbsp;</td>';
					}
					
					if(obj.oldAE === 'C'){
						if(obj.oldSumsAE !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsAE)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsAE)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldAE === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldAE) + '&nbsp;</td>';
					}
					
					if(obj.oldINST === 'C'){
						if(obj.oldSumsINST !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsINST)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsINST)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldINST === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldINST) + '&nbsp;</td>';
					}
					
					if(obj.oldIP === 'C'){
						if(obj.oldSumsIP !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsIP)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsIP)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldIP === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldIP) + '&nbsp;</td>';
					}
					
					if(obj.oldDMIS === 'C'){
						if(obj.oldSumsDMIS !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsDMIS)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsDMIS)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldDMIS === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldDMIS) + '&nbsp;</td>';
					}
					
					if(obj.oldOP === 'C'){
						if(obj.oldSumsOP !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsOP)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsOP)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldOP === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldOP) + '&nbsp;</td>';
					}
					
					if(obj.oldPA === 'C'){
						if(obj.oldSumsPA !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsPA)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsPA)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldPA === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldPA) + '&nbsp;</td>';
					}
					
					if(obj.oldSumsDRUG !== 0){
						tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsDRUG)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsDRUG)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}
					
					if(obj.oldOT === 'C'){
						if(obj.oldSumsOT !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.oldSumsOT)) + '">' + nullToEmpty(currency2Digit(obj.oldSumsOT)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
						}
					}else if(obj.oldOT === 'N'){
						tb += '<td width="100px" class="amount hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.oldOT) + '&nbsp;</td>';
					}
					tb += '<td width="100px" style="text-align:right"  class="hidden-table">' + nullToEmpty(currency2Digit(obj.oldAmount)) + '&nbsp;</td>';
					
					
					tb += '<td width="100px" style="text-align:right"  class="hidden-table">' + nullToEmpty(currency2Digit(obj.discharge)) + '&nbsp;</td>';							
					if(obj.hc === 'C'){
						if(obj.sumsHC !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsHC)) + '">' + nullToEmpty(currency2Digit(obj.sumsHC)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.hc === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.hc) + '&nbsp;</td>';
					}
					
					if(obj.ae === 'C'){
						if(obj.sumsAE !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsAE)) + '">' + nullToEmpty(currency2Digit(obj.sumsAEStr)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.ae === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.ae) + '&nbsp;</td>';
					}
					
					if(obj.inst === 'C'){
						if(obj.sumsINST !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsINST)) + '">' + nullToEmpty(currency2Digit(obj.sumsINST)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.inst === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.inst) + '&nbsp;</td>';
					}
					
					if(obj.ip === 'C'){
						if(obj.sumsIP !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsIP)) + '">' + nullToEmpty(currency2Digit(obj.sumsIP)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.ip === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.ip) + '&nbsp;</td>';
					}
					
					if(obj.dmis === 'C'){
						if(obj.sumsDMIS !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsDMIS)) + '">' + nullToEmpty(currency2Digit(obj.sumsDMIS)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.dmis === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.dmis) + '&nbsp;</td>';
					}
					
					if(obj.op === 'C'){
						if(obj.sumsOP !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsOP)) + '">' + nullToEmpty(currency2Digit(obj.sumsOP)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.op === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.op) + '&nbsp;</td>';
					}
					
					if(obj.pa === 'C'){
						if(obj.sumsPA !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsPA)) + '">' + nullToEmpty(currency2Digit(obj.sumsPA)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.pa === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.pa) + '&nbsp;</td>';
					}
					
					if(obj.sumsDRUG !== 0){
						tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsDRUG)) + '">' + nullToEmpty(currency2Digit(obj.sumsDRUG)) + '&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}
					
					if(obj.ot === 'C'){
						if(obj.sumsOT !== 0){
							tb += '<td width="100px" class="amount hidden-table" title="' + nullToEmpty(currency2Digit(obj.sumsOT)) + '">' + nullToEmpty(currency2Digit(obj.sumsOT)) + '&nbsp;</td>';
						}else{
							tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
						}
					}else if(obj.ot === 'N'){
						tb += '<td width="100px" class="hidden-table">&nbsp;</td>';
					}else{
						tb += '<td width="100px" class="hidden-table">' + nullToEmpty(obj.ot) + '&nbsp;</td>';
					}
					
					tb += '<td width="100px" style="text-align:right"  class="hidden-table">' + nullToEmpty(currency2Digit(obj.compensation)) + '&nbsp;</td>';
					var amnt = obj.oldAmount - obj.compensation;
					var pay = 0;
					var payReturn = 0;
					if(amnt < 0){
						pay = obj.compensation - obj.oldAmount;
						payReturn = 0;
					}else{
						pay = 0;
						payReturn = amnt;
					}
					
					tb += '<td width="100px" style="text-align:right" class="hidden-table">' + currency2Digit(pay) + '&nbsp;</td>';
					tb += '<td width="100px" style="text-align:right" class="hidden-table">' + currency2Digit(payReturn) + '&nbsp;</td>';

				}
				tb += '</tr>';
				
				totalSalaryAmount += obj.salaryAmount;
				totalDischarge += obj.discharge;
				totalChargeRule += obj.chargeRule;
				totalCompensation += obj.compensation;
				
				totalOrfHMain += obj.orfHMain;
				totalOrfNHSO += obj.orfNHSO;
				
				totalSumHC += obj.sumsHC;
				totalSumAE += obj.sumsAE;
				totalSumINST += obj.sumsINST;
				totalSumIP += obj.sumsIP;
				totalSumDMIS += obj.sumsDMIS;
				totalSumOP += obj.sumsOP;
				totalSumPA += obj.sumsPA;
				totalSumOT += obj.sumsOT;
				totalSumDRUG += obj.sumsDRUG;
				
				totalOldTotal += obj.oldTotal;
				totalOldSumHC += obj.oldSumsHC;
				totalOldSumAE += obj.oldSumsAE;
				totalOldSumINST += obj.oldSumsINST;
				totalOldSumIP += obj.oldSumsIP;
				totalOldSumDMIS += obj.oldSumsDMIS;
				totalOldSumOP += obj.oldSumsOP;
				totalOldSumPA += obj.oldSumsPA;
				totalOldSumOT += obj.oldSumsOT;
				totalOldSumDRUG += obj.oldSumsDRUG;
				totalOldAmount += obj.oldAmount;
				
				if(obj.status === 'A'){
					countStatusA += 1;
					totalNewDischarge += obj.discharge;
					totalNewCompensation += obj.compensation;
					totalNewSumHC += obj.sumsHC;
					totalNewSumAE += obj.sumsAE;
					totalNewSumINST += obj.sumsINST;
					totalNewSumIP += obj.sumsIP;
					totalNewSumDMIS += obj.sumsDMIS;
					totalNewSumOP += obj.sumsOP;
					totalNewSumPA += obj.sumsPA;
					totalNewSumOT += obj.sumsOT;
					totalNewSumDRUG += obj.sumsDRUG;
					
					amnt = obj.oldAmount - obj.compensation;
					pay = 0;
					payReturn = 0;
					if(amnt < 0){
						pay = obj.compensation - obj.oldAmount;
					}else{
						payReturn = amnt;
					}
					totalPay += pay;
					totalReturn += payReturn;
				}
			}
			
			var totalDisComTotal = totalDischarge - totalCompensation;
			var clazzDisComTotal = '';
			if(totalDisComTotal < 0){
				clazzDisComTotal = 'required';
			}
			
			if(end >= cntAll){
			tb += '<tr style="background-color: rgb(224,224,224);">';
			tb += '<td colspan="10" style="text-align: center"><strong>รวม</strong>&nbsp;</td>';
			tb += '<td width="70px"></td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSalaryAmount) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalDischarge) + '&nbsp;</td>';
			tb += '<td width="60px"></td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalChargeRule) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalCompensation) + '&nbsp;</td>';
			tb += '<td width="100px" align="right" class="' + clazzDisComTotal + '">' + currency2Digit(totalDisComTotal) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalOrfHMain) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalOrfNHSO) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumHC) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumAE) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumINST) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumIP) + '&nbsp;</td>';										
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumDMIS) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumOP) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumPA) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumDRUG) + '&nbsp;</td>';
			tb += '<td width="100px" align="right">' + currency2Digit(totalSumOT) + '&nbsp;</td>';

			if(countStatusA > 0){
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldTotal) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumHC) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumAE) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumINST) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumIP) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumDMIS) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumOP) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumPA) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumDRUG) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldSumOT) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalOldAmount) + '&nbsp;</td>';
				
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewDischarge) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumHC) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumAE) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumINST) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumIP) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumDMIS) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumOP) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumPA) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumDRUG) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewSumOT) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalNewCompensation) + '&nbsp;</td>';
				
				var tt = totalPay - totalReturn;
				if(tt < 0){
					totalReturn = totalReturn - totalPay;
					totalPay = 0;
				}else{
					totalReturn = 0;
					totalPay = tt;
				}
				
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalPay) + '&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">' + currency2Digit(totalReturn) + '&nbsp;</td>';
			}else{
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
				tb += '<td width="100px" align="right" class="hidden-table">&nbsp;</td>';
			}
			tb += '</tr>';
			}
			
			if('${SESSION_SUMMARY.pageDetailsData.status}' === 'compensation'){
				$('#sumsActAmount').html(currency2Digit(actAmount));
			}
			
			if($("#searchBy").val() !== ''){
				$('#cntAllpid').html(arrays.length);
				$('#personPass').html(arrays.length - cntPersonAppeal - cntPersonNotPass - cntStandardNotPass);
				$('#personAppeal').html(cntPersonAppeal);
				$('#personNotPass').html(cntPersonNotPass);
				$('#standardNotPass').html(cntStandardNotPass);
				$('#sumsTotal').html(currency2Digit(sumsTotal));
				$('#sumsActAmount').html(currency2Digit(actAmount));
				if(cntPersonAppeal > 0){
					$('#sumsActAmount').html(currency2Digit(totalPay - totalReturn));
				}
			}
		}else{
			$('#cntAllpid').html(0);
			$('#personPass').html(0);
			$('#personAppeal').html(0);
			$('#personNotPass').html(0);
			$('#standardNotPass').html(0);
			$('#sumsTotal').html("0.00");
			$('#sumsActAmount').html("0.00");
			tb = '<tr><td colspan="26" class="required">ไม่มีข้อมูล</td></tr>';
		}
		
		$("#tbBodyData tbody").html(tb);
		$('.hidden-table').hide();
	}
	
	function clearData(){
		loadingScroll = DEFAULT_SCROLL;
		start = 0;
		end = 1000;
		cntAll = 0;
		totalSalaryAmount = 0;
		totalDischarge = 0;
		totalChargeRule = 0;
		totalCompensation = 0;
		
		totalSumHC = 0;
		totalSumAE = 0;
		totalSumINST = 0;
		totalSumIP = 0;
		totalSumDMIS = 0;
		totalSumOP = 0;
		totalSumPA = 0;
		totalSumOT = 0;
		totalSumDRUG = 0;
		
		totalOldTotal = 0;
		totalOldSumHC = 0;
		totalOldSumAE = 0;
		totalOldSumINST = 0;
		totalOldSumIP = 0;
		totalOldSumDMIS = 0;
		totalOldSumOP = 0;
		totalOldSumPA = 0;
		totalOldSumOT = 0;
		totalOldSumDRUG = 0;
		totalOldAmount = 0;
		
		totalNewSumHC = 0;
		totalNewSumAE = 0;
		totalNewSumINST = 0;
		totalNewSumIP = 0;
		totalNewSumDMIS = 0;
		totalNewSumOP = 0;
		totalNewSumPA = 0;
		totalNewSumOT = 0;
		totalNewSumDRUG = 0;
		totalNewDischarge = 0;
		totalNewCompensation = 0;
		
		totalPay = 0;
		totalReturn = 0;
		
		countStatusA = 0;
	}
</script>

<style>
.table-dialog {
	overflow: auto;
}

.table-dialog div {
	margin-bottom: 10px;
	text-align: center;
}

.table-dialog div table,.table-dialog div table thead tr td {
	width: 1250px;
	border: solid #000 1px;
}

.table-dialog div table thead tr {
	background: #a3d9ff;
	font-weight: bold;
	font-size: 14px;
	text-align: center;
	height: 30px;
}

.table-dialog div table tbody tr {
	font-size: 13px;
	text-align: center;
	height: 35px;
}

.table-dialog div table tbody tr td {
	padding: 5px;
	border: solid #000 1px;
}

.amount {
	color: blue;
	text-align: right;
}
</style>
</head>

<body>
	<iframe id="txtArea1" style="display: none"></iframe>
	<!------------------- Header ------------------>
	<div class="panel">
		<jsp:include page="../include/header.jsp" />
	</div>
	<!--------------------------------------------->

	<div class="block-content">
		<jsp:include page="../include/breadcrumb.jsp" />

		<div id="content" class="content-data">
			<div class="panel">
				<div class="panel-content text-center">
					<div>
						<b>${SESSION_SUMMARY.pageDetailsData.zone.zoneName}</b>&nbsp;&nbsp;จังหวัด&nbsp;<b>${SESSION_SUMMARY.pageDetailsData.province.provinceName}</b>&nbsp;&nbsp;
						<c:if test="${not empty SESSION_SUMMARY.pageDetailsData.hospital}">
							หน่วยบริการ&nbsp;<b><span id="hospitalCode"></span>&nbsp;${SESSION_SUMMARY.pageDetailsData.hospital.hospitalName}</b>
						</c:if>
					</div>
					<div>
						ข้อมูลจากวันที่&nbsp;<b id="fromDate"></b>
						ถึงวันที่&nbsp;<b id="toDate"></b>
					</div>
					<div>
						เลขที่ใบรายงาน&nbsp;<b>${SESSION_SUMMARY.pageDetailsData.repNo}</b>&nbsp;สถานะ <span
							style="font-weight: bold; text-decoration: underline;"> 
							<c:choose>
								<c:when test="${USER.userType eq 'Employee' }">
									<c:choose>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'compensation'}">ตรวจสอบชดเชย</c:when>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'patition'}">อนุมัติจ่ายชดเชย</c:when>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'budget'}">ตัดงบประมาณ</c:when>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'payable'}">ตั้งหนี้</c:when>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'transfer'}">ตัดจ่าย</c:when>
									</c:choose>
								</c:when>
								<c:otherwise>
									<c:choose>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'payable'}">ตั้งหนี้</c:when>
										<c:when test="${SESSION_SUMMARY.pageDetailsData.status eq 'transfer'}">ตัดจ่าย</c:when>
										<c:otherwise>ระหว่างประมวลผล</c:otherwise>
									</c:choose>
								</c:otherwise>
							</c:choose>
						</span>
					</div>
					<div>
						จำนวนรายทั้งหมด&nbsp;<b id="cntAllpid"></b>&nbsp;ราย&nbsp;ผ่าน
						<font style="font-weight: bold; text-decoration: underline;"
							id="personPass"></font>&nbsp;ราย&nbsp;อุทธรณ์
						<font style="font-weight: bold; text-decoration: underline;"
							id="personAppeal"></font>&nbsp;ราย&nbsp;ไม่ผ่าน
						<font style="font-weight: bold; text-decoration: underline;"
							id="personNotPass"></font>&nbsp;ราย&nbsp;ไม่เข้าเกณฑ์
						<font style="font-weight: bold; text-decoration: underline;"
							id="standardNotPass"></font>&nbsp;ราย
					</div>
					<div>
						ยอดเรียกเก็บ&nbsp;<b id="sumsTotal"></b>&nbsp;บาท&nbsp;
						ไม่ผ่าน&nbsp;<b id="sumsNotPass"></b>&nbsp;บาท&nbsp;&nbsp;
						ไม่เข้าเกณฑ์&nbsp;<b id="sumsNotPassC"></b>&nbsp;บาท&nbsp;&nbsp;
						ชดเชยทั้งสิ้น&nbsp; <b id="sumsActAmount"></b> บาท
					</div>
					<div style="margin-top: 5px;">
						ค้นหาจาก <select id="searchBy" style="width: 100px;">
							<option value="" selected="selected">ทั้งหมด</option>
							<option value="status">สถานะ</option>
							<option value="pid">PID</option>
							<option value="hn">HN</option>
							<option value="an">AN</option>
						</select> &nbsp;<input type="text" id="txtSearch">&nbsp;
						<select id="searchByStatus" style="width: 150px; display: none;">
							<option value="pass" selected="selected">ผ่าน</option>
							<option value="notPass">ไม่ผ่าน</option>
							<option value="notPassC">ไม่เข้าเกณฑ์</option>
							<option value="appeal">อุทธรณ์</option>
						</select>
						<button id="btnSearch">ค้นหา</button>
					</div>
					<div style="float:left">
					<div style="text-align: left; margin: 1px;">
						<img alt="Export to Excel"
							src="${pageContext.request.contextPath}/images/file_xls.gif"
							class="pointer-cursor" title="Export to Excel" id="exportExcel">
							
						<span style="color: red; font-size: 14px; margin-left: 10px" id="orf"></span>
					</div>
					<c:if test="${not empty SESSION_SUMMARY.pageDetailsData.regupPayableBeans}">
						<div style="margin-top: 3px">
							<div style="float: left; margin-bottom: 10px">
								<table width="600px" cellspacing="0" cellpadding="0"
									id="tbBatch">
									<thead>
										<tr
											style="background: #a3d9ff; font-weight: bold; font-size: 14px; height: 20px;">
											<td style="border: 1px solid #000000; border-right: 0px;"
												width="100px">Batch Id</td>
											<td width="200px"
												style="border: 1px solid #000000; border-right: 0px;">วันที่จ่าย</td>
											<td style="border: 1px solid #000000;">จำนวนเงิน</td>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${SESSION_SUMMARY.pageDetailsData.regupPayableBeans}"
											var="x" varStatus="i">
											<tr style="font-size: 13px; height: 35px;">

												<td
													style="border: 1px solid #000000; border-right: 0px; border-top: 0px">${x.batchId
													}</td>
												<td
													style="border: 1px solid #000000; border-right: 0px; border-top: 0px">${x.strRunDate
													}</td>
												<td
													style="border: 1px solid #000000; padding-right: 5px; border-top: 0px"
													align="right"><c:choose>
														<c:when test="${x.expression eq 'H' }">
															<fmt:formatNumber value="${x.amount }" pattern="#,##0.00" />
														</c:when>
														<c:when test="${x.expression eq 'S' }">
															<span style="color: red">-<fmt:formatNumber
																	value="${x.amount }" pattern="#,##0.00" /></span>
														</c:when>
													</c:choose></td>

											</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
							<div style="color: red; font-size: 14px; float: left; position: relative; bottom: -15px; margin-left: 10px">
								*หมายเหตุ กรณีเรียกคืน/หักหนี้ ไม่สามารถระบุ PID ได้<br>
									<span style="position: absolute; left: 0; margin-left: 0;" id="orfTransfer"></span>
							</div>
						</div>
					</c:if>
					</div>
					<div style="float: right; margin: 1px;">
							<button id="show_table"><img width="12px" src="${pageContext.request.contextPath}/images/arrow_right.png" /> แสดงข้อมูลอุทธรณ์</button>
							<button id="hide_table"><img width="12px" src="${pageContext.request.contextPath}/images/arrow_left.png" /> ซ่อนข้อมูลอุทธรณ์</button>
					</div>
					<div class="data-table">
						<table width="5720px" cellspacing="0" cellpadding="0"
							id="tbHeaderData" style="padding-right: 17px;">
							<thead id="thead1">
								<tr>
									<td rowspan="3" width="40px">ลำดับ</td>
									<td rowspan="3" width="100px">Tran Id</td>
									<td rowspan="3" width="100px">Eclaim No</td>
									<td rowspan="3" width="70px">HN</td>
									<td rowspan="3" width="70px">AN</td>
									<td rowspan="3" width="95px">PID</td>
									<td rowspan="3" width="50px">OP/IP</td>
									<td rowspan="3" width="180px">ชื่อ-นามสกุล</td>
									<td rowspan="3" width="110px">วันที่เข้ารับการรักษา</td>
									<td rowspan="3" width="110px">วันที่จำหน่าย</td>
									<td rowspan="2" colspan="2">เงินเดือน</td>
									<td rowspan="3" width="100px">เรียกเก็บ&nbsp;(บาท)</td>
									<td rowspan="3" width="60px">สถานะ</td>
									<td rowspan="3" width="100px">ค่า พรบ.&nbsp;(บาท)</td>
									<td rowspan="3" width="100px">ชดเชย&nbsp;(บาท)</td>
									<td rowspan="3" width="100px">ส่วนต่างจากการเรียกเก็บ&nbsp;(บาท)</td>
									<td rowspan="2" colspan="2">OP&nbsp;REFER(NON&nbsp;HC)</td>
									<td colspan="9" rowspan="1">กองทุน&nbsp;(บาท)</td>
								</tr>
								<tr>
									<td>HC</td>
									<td>AE</td>
									<td>INST</td>
									<td>IP</td>
									<td>DMIS</td>
									<td>OP</td>
									<td>Prior<br>Authorize</td>
									<td>DRUG</td>
									<td>ON TOP</td>
								</tr>
								<tr>
									<td width="70px">ร้อยละ(%)</td>
									<td width="100px">จำนวนเงิน(บาท)</td>
									<td width="100px">HMAIN</td>
									<td width="100px">NHSO</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
								</tr>
							</thead>
							<thead id="thead2" style="display:none">
								<tr>
									<td rowspan="4" width="40px">ลำดับ</td>
									<td rowspan="4" width="100px">Tran Id</td>
									<td rowspan="4" width="100px">Eclaim No</td>
									<td rowspan="4" width="70px">HN</td>
									<td rowspan="4" width="70px">AN</td>
									<td rowspan="4" width="95px">PID</td>
									<td rowspan="4" width="50px">OP/IP</td>
									<td rowspan="4" width="180px">ชื่อ-นามสกุล</td>
									<td rowspan="4" width="110px">วันที่เข้ารับการรักษา</td>
									<td rowspan="4" width="110px">วันที่จำหน่าย</td>
									<td rowspan="3" colspan="2">เงินเดือน</td>
									<td rowspan="4" width="100px">เรียกเก็บ&nbsp;(บาท)</td>
									<td rowspan="4" width="60px">สถานะ</td>
									<td rowspan="4" width="100px">ค่า พรบ.&nbsp;(บาท)</td>
									<td rowspan="4" width="100px">ชดเชย&nbsp;(บาท)</td>
									<td rowspan="4" width="100px">ส่วนต่างจากการเรียกเก็บ&nbsp;(บาท)</td>
									<td rowspan="3" colspan="2">OP&nbsp;REFER(NON&nbsp;HC)</td>
									<td colspan="9" rowspan="2">กองทุน&nbsp;(บาท)</td>
									<td colspan="24">ข้อมูลอุทธรณ์</td>
								</tr>
								<tr>
									<td colspan="11" width="300px">ข้อมูลเดิม</td>
									<td colspan="11" width="300px">ข้อมูลใหม่</td>
									<td colspan="2" width="200px">ชดเชยสุทธิ</td>
								</tr>
								<tr>
									<td>HC</td>
									<td>AE</td>
									<td>INST</td>
									<td>IP</td>
									<td>DMIS</td>
									<td>OP</td>
									<td>Prior<br>Authorize</td>
									<td>DRUG</td>
									<td>ON TOP</td>
									<!-- Appeal -->
									<td rowspan="2" width="100px">เรียกเก็บ(บาท)</td>
									<td>HC</td>
									<td>AE</td>
									<td>INST</td>
									<td>IP</td>
									<td>DMIS</td>
									<td>OP</td>
									<td>Prior<br>Authorize</td>
									<td>DRUG</td>
									<td>ON TOP</td>
									<td rowspan="2" width="100px">จ่ายชดเชย</td>
									<td rowspan="2" width="100px">เรียกเก็บ(บาท)</td>
									<td>HC</td>
									<td>AE</td>
									<td>INST</td>
									<td>IP</td>
									<td>DMIS</td>
									<td>OP</td>
									<td>Prior<br>Authorize</td>
									<td>DRUG</td>
									<td>ON TOP</td>
									<td rowspan="2" width="100px">จ่ายชดเชย</td>
									<td width="100px" rowspan="2">จ่ายเพิ่ม</td>
									<td width="100px" rowspan="2">เรียกคืน</td>
								</tr>
								<tr>
									<td width="70px">ร้อยละ(%)</td>
									<td width="100px">จำนวนเงิน(บาท)</td>
									<td width="100px">HMAIN</td>
									<td width="100px">NHSO</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<!-- Appeal -->
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>

									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
									<td width="100px">สปสช.จ่าย</td>
								</tr>
							</thead>
						</table>

						<div style="overflow-y: auto; overflow-x: hidden; position: absolute; height: 390px;"
							id="tbValueData">
							<table width="5920px" cellspacing="0" cellpadding="0" id="tbBodyData" style="padding-right: 17px;">
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="dlgAppeal" style="display: none;">
		<div class="table-dialog">
			<div>
				<b>ข้อมูลอุทธรณ์</b>
				<table cellspacing="0" cellpadding="0">
					<thead>
						<tr height="50px">
							<td colspan="2">ข้อมูลเดิม</td>
							<td rowspan="3" width="100px">จ่ายชดเชย</td>
							<td colspan="2">ข้อมูลใหม่</td>
							<td rowspan="3" width="100px">จ่ายชดเชย</td>
							<td colspan="2">ชดเชยสุทธิ</td>

						</tr>
						<tr>
							<td colspan="2"><span id="appealOldFund"></span></td>
							<td colspan="2"><span id="appealNewFund"></span></td>
							<td width="100px" rowspan="2">จ่ายเพิ่ม</td>
							<td width="100px" rowspan="2">เรียกคืน</td>
						</tr>
						<tr>
							<td width="80px">ขอเบิก</td>
							<td width="80px">สปสช.จ่าย</td>
							<td width="80px">ขอเบิก</td>
							<td width="80px">สปสช.จ่าย</td>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td align="right"><span style="color: #00C"
								id="appealOldTotal"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealOldAmount"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealOldPay"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealNewTotal"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealNewAmount"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealNewPay"></span></td>
							<td align="right"><span style="color: #00C" id="appealPay"></span></td>
							<td align="right"><span style="color: #00C"
								id="appealReturn"></span></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
</html>
